package dangs.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import dangs.vo.LocationVO;

public class LocationDAO {
	private SqlMapClientTemplate client;
	public LocationDAO(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public void locationRegister(LocationVO lvo) throws SQLException{
		client.insert("registerLocation", lvo);
	}
	
	public void updateLocation(LocationVO lvo) throws SQLException{
		client.update("updateLocation", lvo);
	}
	
	public ArrayList selectAllLocation() throws SQLException{
		ArrayList list = (ArrayList) client.queryForList("selectAllLocation");
		return list;
	}
	
	public LocationVO selectByLocationId(String locationCode) throws SQLException{
		System.out.println(locationCode);
		LocationVO lvo = (LocationVO) client.queryForObject("selectByLocationId", locationCode);
		return lvo;
	}
	public void deleteByLocationId(LocationVO lvo) throws SQLException{
		String locationCode = lvo.getLocationCode();
		client.delete("deleteByLocationId", locationCode);
	}
}
